package org.htmlparser.util;

import org.htmlparser.util.sort.Sort;

public class Translate
{
  protected static final int BREAKPOINT = 256;
  public static boolean DECODE_LINE_BY_LINE = false;
  public static boolean ENCODE_HEXADECIMAL = false;
  protected static final CharacterReference[] mCharacterList;
  protected static final CharacterReference[] mCharacterReferences;

  static
  {
    CharacterReference[] arrayOfCharacterReference = new CharacterReference[252];
    arrayOfCharacterReference[0] = new CharacterReference("nbsp", 160);
    arrayOfCharacterReference[1] = new CharacterReference("iexcl", 161);
    arrayOfCharacterReference[2] = new CharacterReference("cent", 162);
    arrayOfCharacterReference[3] = new CharacterReference("pound", 163);
    arrayOfCharacterReference[4] = new CharacterReference("curren", 164);
    arrayOfCharacterReference[5] = new CharacterReference("yen", 165);
    arrayOfCharacterReference[6] = new CharacterReference("brvbar", 166);
    arrayOfCharacterReference[7] = new CharacterReference("sect", 167);
    arrayOfCharacterReference[8] = new CharacterReference("uml", 168);
    arrayOfCharacterReference[9] = new CharacterReference("copy", 169);
    arrayOfCharacterReference[10] = new CharacterReference("ordf", 170);
    arrayOfCharacterReference[11] = new CharacterReference("laquo", 171);
    arrayOfCharacterReference[12] = new CharacterReference("not", 172);
    arrayOfCharacterReference[13] = new CharacterReference("shy", 173);
    arrayOfCharacterReference[14] = new CharacterReference("reg", 174);
    arrayOfCharacterReference[15] = new CharacterReference("macr", 175);
    arrayOfCharacterReference[16] = new CharacterReference("deg", 176);
    arrayOfCharacterReference[17] = new CharacterReference("plusmn", 177);
    arrayOfCharacterReference[18] = new CharacterReference("sup2", 178);
    arrayOfCharacterReference[19] = new CharacterReference("sup3", 179);
    arrayOfCharacterReference[20] = new CharacterReference("acute", 180);
    arrayOfCharacterReference[21] = new CharacterReference("micro", 181);
    arrayOfCharacterReference[22] = new CharacterReference("para", 182);
    arrayOfCharacterReference[23] = new CharacterReference("middot", 183);
    arrayOfCharacterReference[24] = new CharacterReference("cedil", 184);
    arrayOfCharacterReference[25] = new CharacterReference("sup1", 185);
    arrayOfCharacterReference[26] = new CharacterReference("ordm", 186);
    arrayOfCharacterReference[27] = new CharacterReference("raquo", 187);
    arrayOfCharacterReference[28] = new CharacterReference("frac14", 188);
    arrayOfCharacterReference[29] = new CharacterReference("frac12", 189);
    arrayOfCharacterReference[30] = new CharacterReference("frac34", 190);
    arrayOfCharacterReference[31] = new CharacterReference("iquest", 191);
    arrayOfCharacterReference[32] = new CharacterReference("Agrave", 192);
    arrayOfCharacterReference[33] = new CharacterReference("Aacute", 193);
    arrayOfCharacterReference[34] = new CharacterReference("Acirc", 194);
    arrayOfCharacterReference[35] = new CharacterReference("Atilde", 195);
    arrayOfCharacterReference[36] = new CharacterReference("Auml", 196);
    arrayOfCharacterReference[37] = new CharacterReference("Aring", 197);
    arrayOfCharacterReference[38] = new CharacterReference("AElig", 198);
    arrayOfCharacterReference[39] = new CharacterReference("Ccedil", 199);
    arrayOfCharacterReference[40] = new CharacterReference("Egrave", 200);
    arrayOfCharacterReference[41] = new CharacterReference("Eacute", 201);
    arrayOfCharacterReference[42] = new CharacterReference("Ecirc", 202);
    arrayOfCharacterReference[43] = new CharacterReference("Euml", 203);
    arrayOfCharacterReference[44] = new CharacterReference("Igrave", 204);
    arrayOfCharacterReference[45] = new CharacterReference("Iacute", 205);
    arrayOfCharacterReference[46] = new CharacterReference("Icirc", 206);
    arrayOfCharacterReference[47] = new CharacterReference("Iuml", 207);
    arrayOfCharacterReference[48] = new CharacterReference("ETH", 208);
    arrayOfCharacterReference[49] = new CharacterReference("Ntilde", 209);
    arrayOfCharacterReference[50] = new CharacterReference("Ograve", 210);
    arrayOfCharacterReference[51] = new CharacterReference("Oacute", 211);
    arrayOfCharacterReference[52] = new CharacterReference("Ocirc", 212);
    arrayOfCharacterReference[53] = new CharacterReference("Otilde", 213);
    arrayOfCharacterReference[54] = new CharacterReference("Ouml", 214);
    arrayOfCharacterReference[55] = new CharacterReference("times", 215);
    arrayOfCharacterReference[56] = new CharacterReference("Oslash", 216);
    arrayOfCharacterReference[57] = new CharacterReference("Ugrave", 217);
    arrayOfCharacterReference[58] = new CharacterReference("Uacute", 218);
    arrayOfCharacterReference[59] = new CharacterReference("Ucirc", 219);
    arrayOfCharacterReference[60] = new CharacterReference("Uuml", 220);
    arrayOfCharacterReference[61] = new CharacterReference("Yacute", 221);
    arrayOfCharacterReference[62] = new CharacterReference("THORN", 222);
    arrayOfCharacterReference[63] = new CharacterReference("szlig", 223);
    arrayOfCharacterReference[64] = new CharacterReference("agrave", 224);
    arrayOfCharacterReference[65] = new CharacterReference("aacute", 225);
    arrayOfCharacterReference[66] = new CharacterReference("acirc", 226);
    arrayOfCharacterReference[67] = new CharacterReference("atilde", 227);
    arrayOfCharacterReference[68] = new CharacterReference("auml", 228);
    arrayOfCharacterReference[69] = new CharacterReference("aring", 229);
    arrayOfCharacterReference[70] = new CharacterReference("aelig", 230);
    arrayOfCharacterReference[71] = new CharacterReference("ccedil", 231);
    arrayOfCharacterReference[72] = new CharacterReference("egrave", 232);
    arrayOfCharacterReference[73] = new CharacterReference("eacute", 233);
    arrayOfCharacterReference[74] = new CharacterReference("ecirc", 234);
    arrayOfCharacterReference[75] = new CharacterReference("euml", 235);
    arrayOfCharacterReference[76] = new CharacterReference("igrave", 236);
    arrayOfCharacterReference[77] = new CharacterReference("iacute", 237);
    arrayOfCharacterReference[78] = new CharacterReference("icirc", 238);
    arrayOfCharacterReference[79] = new CharacterReference("iuml", 239);
    arrayOfCharacterReference[80] = new CharacterReference("eth", 240);
    arrayOfCharacterReference[81] = new CharacterReference("ntilde", 241);
    arrayOfCharacterReference[82] = new CharacterReference("ograve", 242);
    arrayOfCharacterReference[83] = new CharacterReference("oacute", 243);
    arrayOfCharacterReference[84] = new CharacterReference("ocirc", 244);
    arrayOfCharacterReference[85] = new CharacterReference("otilde", 245);
    arrayOfCharacterReference[86] = new CharacterReference("ouml", 246);
    arrayOfCharacterReference[87] = new CharacterReference("divide", 247);
    arrayOfCharacterReference[88] = new CharacterReference("oslash", 248);
    arrayOfCharacterReference[89] = new CharacterReference("ugrave", 249);
    arrayOfCharacterReference[90] = new CharacterReference("uacute", 250);
    arrayOfCharacterReference[91] = new CharacterReference("ucirc", 251);
    arrayOfCharacterReference[92] = new CharacterReference("uuml", 252);
    arrayOfCharacterReference[93] = new CharacterReference("yacute", 253);
    arrayOfCharacterReference[94] = new CharacterReference("thorn", 254);
    arrayOfCharacterReference[95] = new CharacterReference("yuml", 255);
    arrayOfCharacterReference[96] = new CharacterReference("fnof", 402);
    arrayOfCharacterReference[97] = new CharacterReference("Alpha", 913);
    arrayOfCharacterReference[98] = new CharacterReference("Beta", 914);
    arrayOfCharacterReference[99] = new CharacterReference("Gamma", 915);
    arrayOfCharacterReference[100] = new CharacterReference("Delta", 916);
    arrayOfCharacterReference[101] = new CharacterReference("Epsilon", 917);
    arrayOfCharacterReference[102] = new CharacterReference("Zeta", 918);
    arrayOfCharacterReference[103] = new CharacterReference("Eta", 919);
    arrayOfCharacterReference[104] = new CharacterReference("Theta", 920);
    arrayOfCharacterReference[105] = new CharacterReference("Iota", 921);
    arrayOfCharacterReference[106] = new CharacterReference("Kappa", 922);
    arrayOfCharacterReference[107] = new CharacterReference("Lambda", 923);
    arrayOfCharacterReference[108] = new CharacterReference("Mu", 924);
    arrayOfCharacterReference[109] = new CharacterReference("Nu", 925);
    arrayOfCharacterReference[110] = new CharacterReference("Xi", 926);
    arrayOfCharacterReference[111] = new CharacterReference("Omicron", 927);
    arrayOfCharacterReference[112] = new CharacterReference("Pi", 928);
    arrayOfCharacterReference[113] = new CharacterReference("Rho", 929);
    arrayOfCharacterReference[114] = new CharacterReference("Sigma", 931);
    arrayOfCharacterReference[115] = new CharacterReference("Tau", 932);
    arrayOfCharacterReference[116] = new CharacterReference("Upsilon", 933);
    arrayOfCharacterReference[117] = new CharacterReference("Phi", 934);
    arrayOfCharacterReference[118] = new CharacterReference("Chi", 935);
    arrayOfCharacterReference[119] = new CharacterReference("Psi", 936);
    arrayOfCharacterReference[120] = new CharacterReference("Omega", 937);
    arrayOfCharacterReference[121] = new CharacterReference("alpha", 945);
    arrayOfCharacterReference[122] = new CharacterReference("beta", 946);
    arrayOfCharacterReference[123] = new CharacterReference("gamma", 947);
    arrayOfCharacterReference[124] = new CharacterReference("delta", 948);
    arrayOfCharacterReference[125] = new CharacterReference("epsilon", 949);
    arrayOfCharacterReference[126] = new CharacterReference("zeta", 950);
    arrayOfCharacterReference[127] = new CharacterReference("eta", 951);
    arrayOfCharacterReference[128] = new CharacterReference("theta", 952);
    arrayOfCharacterReference[129] = new CharacterReference("iota", 953);
    arrayOfCharacterReference[130] = new CharacterReference("kappa", 954);
    arrayOfCharacterReference[131] = new CharacterReference("lambda", 955);
    arrayOfCharacterReference[132] = new CharacterReference("mu", 956);
    arrayOfCharacterReference[133] = new CharacterReference("nu", 957);
    arrayOfCharacterReference[134] = new CharacterReference("xi", 958);
    arrayOfCharacterReference[135] = new CharacterReference("omicron", 959);
    arrayOfCharacterReference[136] = new CharacterReference("pi", 960);
    arrayOfCharacterReference[137] = new CharacterReference("rho", 961);
    arrayOfCharacterReference[138] = new CharacterReference("sigmaf", 962);
    arrayOfCharacterReference[139] = new CharacterReference("sigma", 963);
    arrayOfCharacterReference[140] = new CharacterReference("tau", 964);
    arrayOfCharacterReference[141] = new CharacterReference("upsilon", 965);
    arrayOfCharacterReference[142] = new CharacterReference("phi", 966);
    arrayOfCharacterReference[143] = new CharacterReference("chi", 967);
    arrayOfCharacterReference[144] = new CharacterReference("psi", 968);
    arrayOfCharacterReference[145] = new CharacterReference("omega", 969);
    arrayOfCharacterReference[146] = new CharacterReference("thetasym", 977);
    arrayOfCharacterReference[147] = new CharacterReference("upsih", 978);
    arrayOfCharacterReference[148] = new CharacterReference("piv", 982);
    arrayOfCharacterReference[149] = new CharacterReference("bull", 8226);
    arrayOfCharacterReference[150] = new CharacterReference("hellip", 8230);
    arrayOfCharacterReference[151] = new CharacterReference("prime", 8242);
    arrayOfCharacterReference[152] = new CharacterReference("Prime", 8243);
    arrayOfCharacterReference[153] = new CharacterReference("oline", 8254);
    arrayOfCharacterReference[154] = new CharacterReference("frasl", 8260);
    arrayOfCharacterReference[155] = new CharacterReference("weierp", 8472);
    arrayOfCharacterReference[156] = new CharacterReference("image", 8465);
    arrayOfCharacterReference[157] = new CharacterReference("real", 8476);
    arrayOfCharacterReference[158] = new CharacterReference("trade", 8482);
    arrayOfCharacterReference[159] = new CharacterReference("alefsym", 8501);
    arrayOfCharacterReference[160] = new CharacterReference("larr", 8592);
    arrayOfCharacterReference[161] = new CharacterReference("uarr", 8593);
    arrayOfCharacterReference[162] = new CharacterReference("rarr", 8594);
    arrayOfCharacterReference[163] = new CharacterReference("darr", 8595);
    arrayOfCharacterReference[164] = new CharacterReference("harr", 8596);
    arrayOfCharacterReference[165] = new CharacterReference("crarr", 8629);
    arrayOfCharacterReference[166] = new CharacterReference("lArr", 8656);
    arrayOfCharacterReference[167] = new CharacterReference("uArr", 8657);
    arrayOfCharacterReference[168] = new CharacterReference("rArr", 8658);
    arrayOfCharacterReference[169] = new CharacterReference("dArr", 8659);
    arrayOfCharacterReference[170] = new CharacterReference("hArr", 8660);
    arrayOfCharacterReference[171] = new CharacterReference("forall", 8704);
    arrayOfCharacterReference[172] = new CharacterReference("part", 8706);
    arrayOfCharacterReference[173] = new CharacterReference("exist", 8707);
    arrayOfCharacterReference[174] = new CharacterReference("empty", 8709);
    arrayOfCharacterReference[175] = new CharacterReference("nabla", 8711);
    arrayOfCharacterReference[176] = new CharacterReference("isin", 8712);
    arrayOfCharacterReference[177] = new CharacterReference("notin", 8713);
    arrayOfCharacterReference[178] = new CharacterReference("ni", 8715);
    arrayOfCharacterReference[179] = new CharacterReference("prod", 8719);
    arrayOfCharacterReference[180] = new CharacterReference("sum", 8721);
    arrayOfCharacterReference[181] = new CharacterReference("minus", 8722);
    arrayOfCharacterReference[182] = new CharacterReference("lowast", 8727);
    arrayOfCharacterReference[183] = new CharacterReference("radic", 8730);
    arrayOfCharacterReference[184] = new CharacterReference("prop", 8733);
    arrayOfCharacterReference[185] = new CharacterReference("infin", 8734);
    arrayOfCharacterReference[186] = new CharacterReference("ang", 8736);
    arrayOfCharacterReference[187] = new CharacterReference("and", 8743);
    arrayOfCharacterReference[188] = new CharacterReference("or", 8744);
    arrayOfCharacterReference[189] = new CharacterReference("cap", 8745);
    arrayOfCharacterReference[190] = new CharacterReference("cup", 8746);
    arrayOfCharacterReference[191] = new CharacterReference("int", 8747);
    arrayOfCharacterReference[192] = new CharacterReference("there4", 8756);
    arrayOfCharacterReference[193] = new CharacterReference("sim", 8764);
    arrayOfCharacterReference[194] = new CharacterReference("cong", 8773);
    arrayOfCharacterReference[195] = new CharacterReference("asymp", 8776);
    arrayOfCharacterReference[196] = new CharacterReference("ne", 8800);
    arrayOfCharacterReference[197] = new CharacterReference("equiv", 8801);
    arrayOfCharacterReference[198] = new CharacterReference("le", 8804);
    arrayOfCharacterReference[199] = new CharacterReference("ge", 8805);
    arrayOfCharacterReference[200] = new CharacterReference("sub", 8834);
    arrayOfCharacterReference[201] = new CharacterReference("sup", 8835);
    arrayOfCharacterReference[202] = new CharacterReference("nsub", 8836);
    arrayOfCharacterReference[203] = new CharacterReference("sube", 8838);
    arrayOfCharacterReference[204] = new CharacterReference("supe", 8839);
    arrayOfCharacterReference[205] = new CharacterReference("oplus", 8853);
    arrayOfCharacterReference[206] = new CharacterReference("otimes", 8855);
    arrayOfCharacterReference[207] = new CharacterReference("perp", 8869);
    arrayOfCharacterReference[208] = new CharacterReference("sdot", 8901);
    arrayOfCharacterReference[209] = new CharacterReference("lceil", 8968);
    arrayOfCharacterReference[210] = new CharacterReference("rceil", 8969);
    arrayOfCharacterReference[211] = new CharacterReference("lfloor", 8970);
    arrayOfCharacterReference[212] = new CharacterReference("rfloor", 8971);
    arrayOfCharacterReference[213] = new CharacterReference("lang", 9001);
    arrayOfCharacterReference[214] = new CharacterReference("rang", 9002);
    arrayOfCharacterReference[215] = new CharacterReference("loz", 9674);
    arrayOfCharacterReference[216] = new CharacterReference("spades", 9824);
    arrayOfCharacterReference[217] = new CharacterReference("clubs", 9827);
    arrayOfCharacterReference[218] = new CharacterReference("hearts", 9829);
    arrayOfCharacterReference[219] = new CharacterReference("diams", 9830);
    arrayOfCharacterReference[220] = new CharacterReference("quot", 34);
    arrayOfCharacterReference[221] = new CharacterReference("amp", 38);
    arrayOfCharacterReference[222] = new CharacterReference("lt", 60);
    arrayOfCharacterReference[223] = new CharacterReference("gt", 62);
    arrayOfCharacterReference[224] = new CharacterReference("OElig", 338);
    arrayOfCharacterReference[225] = new CharacterReference("oelig", 339);
    arrayOfCharacterReference[226] = new CharacterReference("Scaron", 352);
    arrayOfCharacterReference[227] = new CharacterReference("scaron", 353);
    arrayOfCharacterReference[228] = new CharacterReference("Yuml", 376);
    arrayOfCharacterReference[229] = new CharacterReference("circ", 710);
    arrayOfCharacterReference[230] = new CharacterReference("tilde", 732);
    arrayOfCharacterReference[231] = new CharacterReference("ensp", 8194);
    arrayOfCharacterReference[232] = new CharacterReference("emsp", 8195);
    arrayOfCharacterReference[233] = new CharacterReference("thinsp", 8201);
    arrayOfCharacterReference[234] = new CharacterReference("zwnj", 8204);
    arrayOfCharacterReference[235] = new CharacterReference("zwj", 8205);
    arrayOfCharacterReference[236] = new CharacterReference("lrm", 8206);
    arrayOfCharacterReference[237] = new CharacterReference("rlm", 8207);
    arrayOfCharacterReference[238] = new CharacterReference("ndash", 8211);
    arrayOfCharacterReference[239] = new CharacterReference("mdash", 8212);
    arrayOfCharacterReference[240] = new CharacterReference("lsquo", 8216);
    arrayOfCharacterReference[241] = new CharacterReference("rsquo", 8217);
    arrayOfCharacterReference[242] = new CharacterReference("sbquo", 8218);
    arrayOfCharacterReference[243] = new CharacterReference("ldquo", 8220);
    arrayOfCharacterReference[244] = new CharacterReference("rdquo", 8221);
    arrayOfCharacterReference[245] = new CharacterReference("bdquo", 8222);
    arrayOfCharacterReference[246] = new CharacterReference("dagger", 8224);
    arrayOfCharacterReference[247] = new CharacterReference("Dagger", 8225);
    arrayOfCharacterReference[248] = new CharacterReference("permil", 8240);
    arrayOfCharacterReference[249] = new CharacterReference("lsaquo", 8249);
    arrayOfCharacterReference[250] = new CharacterReference("rsaquo", 8250);
    arrayOfCharacterReference[251] = new CharacterReference("euro", 8364);
    mCharacterReferences = arrayOfCharacterReference;
    int i = 0;
    for (int j = 0; j < mCharacterReferences.length; ++j)
      if (mCharacterReferences[j].getCharacter() < 256)
        ++i;
    mCharacterList = new CharacterReference[256 + mCharacterReferences.length - i];
    int k = 256;
    int l = 0;
    if (l < mCharacterReferences.length)
    {
      CharacterReference localCharacterReference = mCharacterReferences[l];
      int i1 = mCharacterReferences[l].getCharacter();
      if (i1 < 256)
        mCharacterList[i1] = localCharacterReference;
      while (true)
      {
        while (true)
          ++l;
        int i2 = 256;
        while (true)
        {
          if ((i2 >= k) || (mCharacterList[i2].getCharacter() > i1))
          {
            int i3 = k - 1;
            while (true)
            {
              if (i3 < i2)
                break label4473;
              mCharacterList[(i3 + 1)] = mCharacterList[i3];
              --i3;
            }
          }
          ++i2;
        }
        label4473: mCharacterList[i2] = localCharacterReference;
        ++k;
      }
    }
    Sort.QuickSort(mCharacterReferences);
  }

  public static String decode(String paramString)
  {
    int i1;
    Object localObject2;
    Object localObject3;
    char c1;
    int i = paramString.indexOf(38);
    if (-1 == i)
    {
      localObject3 = paramString;
      return localObject3;
    }
    int j = paramString.length();
    StringBuffer localStringBuffer = new StringBuffer(j);
    Object localObject1 = null;
    for (int k = 0; k < i; k = i17)
    {
      int i17 = k + 1;
      localStringBuffer.append(paramString.charAt(k));
    }
    int l = k + 1;
    if (l < j)
    {
      c1 = paramString.charAt(l);
      if ('#' == c1)
      {
        ++l;
        int i10 = 0;
        int i11 = 0;
        int i13 = l;
        int i14 = 0;
        if ((i13 < j) && (i14 == 0))
        {
          int i16 = paramString.charAt(i13);
          switch (i16)
          {
          default:
            i14 = 1;
          case 48:
          case 49:
          case 50:
          case 51:
          case 52:
          case 53:
          case 54:
          case 55:
          case 56:
          case 57:
          case 65:
          case 66:
          case 67:
          case 68:
          case 69:
          case 70:
          case 97:
          case 98:
          case 99:
          case 100:
          case 101:
          case 102:
          case 88:
          case 120:
          case 59:
          }
          while (true)
          {
            while (true)
            {
              while (true)
              {
                while (true)
                {
                  while (true)
                  {
                    while (true)
                    {
                      while (true)
                      {
                        while (true)
                        {
                          while (true)
                          {
                            if (i14 != 0);
                            ++i13;
                          }
                          if (i11 == 0)
                            i11 = 10;
                          i10 = i10 * i11 + i16 - 48;
                        }
                        if (16 != i11)
                          break;
                        i10 = i10 * i11 + 10 + i16 - 65;
                      }
                      i14 = 1;
                    }
                    if (16 != i11)
                      break;
                    i10 = i10 * i11 + 10 + i16 - 97;
                  }
                  i14 = 1;
                }
                if (i11 != 0)
                  break;
                int i12 = 16;
              }
              i14 = 1;
            }
            i14 = 1;
            ++i13;
          }
        }
        if (i10 == 0)
          break label835;
        localStringBuffer.append(i10);
        int i15 = i13;
        k = i15;
        localObject2 = localObject1;
        i1 = i15;
      }
    }
    while (true)
    {
      while (true)
      {
        if (i1 >= k)
          break label728;
        int i3 = i1 + 1;
        localStringBuffer.append(paramString.charAt(i1));
        i1 = i3;
      }
      if (Character.isLetter(c1))
      {
        label616: Object localObject4;
        int i4 = l + 1;
        int i5 = 0;
        int i6 = j;
        while (true)
        {
          while (true)
          {
            char c2;
            while (true)
            {
              if ((i4 >= j) || (i5 != 0))
                break label616;
              c2 = paramString.charAt(i4);
              if (';' != c2)
                break;
              i5 = 1;
              i6 = i4;
              ++i4;
            }
            if (!(Character.isLetterOrDigit(c2)))
              break;
            ++i4;
          }
          i5 = 1;
          i6 = i4;
        }
        if (localObject1 == null)
          localObject4 = new CharacterReferenceEx();
        while (true)
        {
          while (true)
          {
            ((CharacterReferenceEx)localObject4).setKernel(paramString);
            ((CharacterReferenceEx)localObject4).setStart(l);
            ((CharacterReferenceEx)localObject4).setEnd(i6);
            CharacterReference localCharacterReference = lookup((CharacterReference)localObject4);
            if (localCharacterReference != null)
            {
              int i8;
              localStringBuffer.append((char)localCharacterReference.getCharacter());
              int i7 = l + localCharacterReference.getKernel().length();
              if ((i7 < j) && (';' == paramString.charAt(i7)))
                i8 = i7 + 1;
              while (true)
              {
                while (true)
                {
                  int i9 = i8;
                  localObject2 = localObject4;
                  k = i8;
                  i1 = i9;
                }
                if (k < j)
                {
                  label728: i = paramString.indexOf(38, k);
                  if (-1 == i);
                }
                while (true)
                {
                  while (true)
                  {
                    while (true)
                    {
                      while (k < j)
                      {
                        int i2 = k + 1;
                        localStringBuffer.append(paramString.charAt(k));
                        k = i2;
                      }
                      String str = localStringBuffer.toString();
                      localObject3 = str;
                    }
                    localObject1 = localObject2;
                  }
                  i = i1;
                }
                i8 = i7;
              }
            }
            i1 = i;
            localObject2 = localObject4;
            k = l;
          }
          localObject4 = localObject1;
        }
      }
      label835: k = l;
      i1 = i;
      localObject2 = localObject1;
    }
  }

  public static String decode(StringBuffer paramStringBuffer)
  {
    return decode(paramStringBuffer.toString());
  }

  // ERROR //
  public static void decode(java.io.InputStream paramInputStream, java.io.PrintStream paramPrintStream)
  {
    // Byte code:
    //   0: new 615	java/io/BufferedReader
    //   3: dup
    //   4: new 617	java/io/InputStreamReader
    //   7: dup
    //   8: aload_0
    //   9: ldc_w 619
    //   12: invokespecial 622	java/io/InputStreamReader:<init>	(Ljava/io/InputStream;Ljava/lang/String;)V
    //   15: invokespecial 625	java/io/BufferedReader:<init>	(Ljava/io/Reader;)V
    //   18: astore_2
    //   19: new 558	java/lang/StringBuffer
    //   22: dup
    //   23: sipush 1024
    //   26: invokespecial 561	java/lang/StringBuffer:<init>	(I)V
    //   29: astore_3
    //   30: iconst_0
    //   31: istore 4
    //   33: getstatic 17	org/htmlparser/util/Translate:DECODE_LINE_BY_LINE	Z
    //   36: ifeq +147 -> 183
    //   39: aload_2
    //   40: invokevirtual 630	java/io/Reader:read	()I
    //   43: istore 9
    //   45: bipush 255
    //   47: iload 9
    //   49: if_icmpeq +158 -> 207
    //   52: bipush 13
    //   54: iload 9
    //   56: if_icmpeq +10 -> 66
    //   59: bipush 10
    //   61: iload 9
    //   63: if_icmpne +79 -> 142
    //   66: iload 4
    //   68: ifne +22 -> 90
    //   71: aload_1
    //   72: aload_3
    //   73: invokevirtual 605	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   76: invokestatic 608	org/htmlparser/util/Translate:decode	(Ljava/lang/String;)Ljava/lang/String;
    //   79: invokevirtual 635	java/io/PrintStream:print	(Ljava/lang/String;)V
    //   82: aload_3
    //   83: iconst_0
    //   84: invokevirtual 638	java/lang/StringBuffer:setLength	(I)V
    //   87: iconst_1
    //   88: istore 4
    //   90: aload_3
    //   91: iload 9
    //   93: i2c
    //   94: invokevirtual 569	java/lang/StringBuffer:append	(C)Ljava/lang/StringBuffer;
    //   97: pop
    //   98: goto -59 -> 39
    //   101: astore 6
    //   103: aload_1
    //   104: invokevirtual 641	java/io/PrintStream:println	()V
    //   107: aload_1
    //   108: aload 6
    //   110: invokevirtual 644	java/io/IOException:getMessage	()Ljava/lang/String;
    //   113: invokevirtual 646	java/io/PrintStream:println	(Ljava/lang/String;)V
    //   116: aload_1
    //   117: invokevirtual 649	java/io/PrintStream:flush	()V
    //   120: return
    //   121: astore 12
    //   123: new 615	java/io/BufferedReader
    //   126: dup
    //   127: new 617	java/io/InputStreamReader
    //   130: dup
    //   131: aload_0
    //   132: invokespecial 652	java/io/InputStreamReader:<init>	(Ljava/io/InputStream;)V
    //   135: invokespecial 625	java/io/BufferedReader:<init>	(Ljava/io/Reader;)V
    //   138: astore_2
    //   139: goto -120 -> 19
    //   142: iload 4
    //   144: ifeq +19 -> 163
    //   147: aload_1
    //   148: aload_3
    //   149: invokevirtual 605	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   152: invokevirtual 635	java/io/PrintStream:print	(Ljava/lang/String;)V
    //   155: aload_3
    //   156: iconst_0
    //   157: invokevirtual 638	java/lang/StringBuffer:setLength	(I)V
    //   160: iconst_0
    //   161: istore 4
    //   163: aload_3
    //   164: iload 9
    //   166: i2c
    //   167: invokevirtual 569	java/lang/StringBuffer:append	(C)Ljava/lang/StringBuffer;
    //   170: pop
    //   171: goto -132 -> 39
    //   174: astore 5
    //   176: aload_1
    //   177: invokevirtual 649	java/io/PrintStream:flush	()V
    //   180: aload 5
    //   182: athrow
    //   183: aload_2
    //   184: invokevirtual 630	java/io/Reader:read	()I
    //   187: istore 7
    //   189: bipush 255
    //   191: iload 7
    //   193: if_icmpeq +14 -> 207
    //   196: aload_3
    //   197: iload 7
    //   199: i2c
    //   200: invokevirtual 569	java/lang/StringBuffer:append	(C)Ljava/lang/StringBuffer;
    //   203: pop
    //   204: goto -21 -> 183
    //   207: aload_3
    //   208: invokevirtual 653	java/lang/StringBuffer:length	()I
    //   211: ifeq +16 -> 227
    //   214: iload 4
    //   216: ifeq +18 -> 234
    //   219: aload_1
    //   220: aload_3
    //   221: invokevirtual 605	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   224: invokevirtual 635	java/io/PrintStream:print	(Ljava/lang/String;)V
    //   227: aload_1
    //   228: invokevirtual 649	java/io/PrintStream:flush	()V
    //   231: goto -111 -> 120
    //   234: aload_1
    //   235: aload_3
    //   236: invokevirtual 605	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   239: invokestatic 608	org/htmlparser/util/Translate:decode	(Ljava/lang/String;)Ljava/lang/String;
    //   242: invokevirtual 635	java/io/PrintStream:print	(Ljava/lang/String;)V
    //   245: goto -18 -> 227
    //
    // Exception table:
    //   from	to	target	type
    //   0	19	101	java/io/IOException
    //   19	98	101	java/io/IOException
    //   123	171	101	java/io/IOException
    //   183	227	101	java/io/IOException
    //   234	245	101	java/io/IOException
    //   0	19	121	java/io/UnsupportedEncodingException
    //   0	19	174	finally
    //   19	98	174	finally
    //   103	116	174	finally
    //   123	171	174	finally
    //   183	227	174	finally
    //   234	245	174	finally
  }

  public static String encode(int paramInt)
  {
    StringBuffer localStringBuffer = new StringBuffer(13);
    localStringBuffer.append("&#");
    if (ENCODE_HEXADECIMAL)
    {
      localStringBuffer.append("x");
      localStringBuffer.append(Integer.toHexString(paramInt));
    }
    while (true)
    {
      localStringBuffer.append(';');
      return localStringBuffer.toString();
      localStringBuffer.append(paramInt);
    }
  }

  public static String encode(String paramString)
  {
    StringBuffer localStringBuffer = new StringBuffer(6 * paramString.length());
    int i = paramString.length();
    int j = 0;
    if (j < i)
    {
      char c = paramString.charAt(j);
      CharacterReference localCharacterReference = lookup(c);
      if (localCharacterReference != null)
      {
        localStringBuffer.append('&');
        localStringBuffer.append(localCharacterReference.getKernel());
        localStringBuffer.append(';');
      }
      while (true)
      {
        while (true)
          ++j;
        if (c >= '')
        {
          localStringBuffer.append("&#");
          if (ENCODE_HEXADECIMAL)
          {
            localStringBuffer.append("x");
            localStringBuffer.append(Integer.toHexString(c));
          }
          while (true)
          {
            while (true)
              localStringBuffer.append(';');
            localStringBuffer.append(c);
          }
        }
        localStringBuffer.append(c);
      }
    }
    return localStringBuffer.toString();
  }

  // ERROR //
  public static void encode(java.io.InputStream paramInputStream, java.io.PrintStream paramPrintStream)
  {
    // Byte code:
    //   0: new 615	java/io/BufferedReader
    //   3: dup
    //   4: new 617	java/io/InputStreamReader
    //   7: dup
    //   8: aload_0
    //   9: ldc_w 619
    //   12: invokespecial 622	java/io/InputStreamReader:<init>	(Ljava/io/InputStream;Ljava/lang/String;)V
    //   15: invokespecial 625	java/io/BufferedReader:<init>	(Ljava/io/Reader;)V
    //   18: astore_2
    //   19: new 675	java/io/PrintWriter
    //   22: dup
    //   23: new 677	java/io/BufferedWriter
    //   26: dup
    //   27: new 679	java/io/OutputStreamWriter
    //   30: dup
    //   31: aload_1
    //   32: ldc_w 619
    //   35: invokespecial 682	java/io/OutputStreamWriter:<init>	(Ljava/io/OutputStream;Ljava/lang/String;)V
    //   38: invokespecial 685	java/io/BufferedWriter:<init>	(Ljava/io/Writer;)V
    //   41: invokespecial 686	java/io/PrintWriter:<init>	(Ljava/io/Writer;)V
    //   44: astore_3
    //   45: aload_2
    //   46: invokevirtual 630	java/io/Reader:read	()I
    //   49: istore 6
    //   51: bipush 255
    //   53: iload 6
    //   55: if_icmpeq +180 -> 235
    //   58: iload 6
    //   60: i2c
    //   61: istore 7
    //   63: iload 7
    //   65: invokestatic 673	org/htmlparser/util/Translate:lookup	(C)Lorg/htmlparser/util/CharacterReference;
    //   68: astore 8
    //   70: aload 8
    //   72: ifnull +91 -> 163
    //   75: aload_3
    //   76: bipush 38
    //   78: invokevirtual 689	java/io/PrintWriter:print	(C)V
    //   81: aload_3
    //   82: aload 8
    //   84: invokevirtual 599	org/htmlparser/util/CharacterReference:getKernel	()Ljava/lang/String;
    //   87: invokevirtual 690	java/io/PrintWriter:print	(Ljava/lang/String;)V
    //   90: aload_3
    //   91: bipush 59
    //   93: invokevirtual 689	java/io/PrintWriter:print	(C)V
    //   96: goto -51 -> 45
    //   99: astore 5
    //   101: aload_3
    //   102: invokevirtual 691	java/io/PrintWriter:println	()V
    //   105: aload_3
    //   106: aload 5
    //   108: invokevirtual 644	java/io/IOException:getMessage	()Ljava/lang/String;
    //   111: invokevirtual 692	java/io/PrintWriter:println	(Ljava/lang/String;)V
    //   114: aload_3
    //   115: invokevirtual 693	java/io/PrintWriter:flush	()V
    //   118: return
    //   119: astore 9
    //   121: new 615	java/io/BufferedReader
    //   124: dup
    //   125: new 617	java/io/InputStreamReader
    //   128: dup
    //   129: aload_0
    //   130: invokespecial 652	java/io/InputStreamReader:<init>	(Ljava/io/InputStream;)V
    //   133: invokespecial 625	java/io/BufferedReader:<init>	(Ljava/io/Reader;)V
    //   136: astore_2
    //   137: new 675	java/io/PrintWriter
    //   140: dup
    //   141: new 677	java/io/BufferedWriter
    //   144: dup
    //   145: new 679	java/io/OutputStreamWriter
    //   148: dup
    //   149: aload_1
    //   150: invokespecial 696	java/io/OutputStreamWriter:<init>	(Ljava/io/OutputStream;)V
    //   153: invokespecial 685	java/io/BufferedWriter:<init>	(Ljava/io/Writer;)V
    //   156: invokespecial 686	java/io/PrintWriter:<init>	(Ljava/io/Writer;)V
    //   159: astore_3
    //   160: goto -115 -> 45
    //   163: iload 7
    //   165: bipush 127
    //   167: if_icmplt +59 -> 226
    //   170: aload_3
    //   171: ldc_w 657
    //   174: invokevirtual 690	java/io/PrintWriter:print	(Ljava/lang/String;)V
    //   177: getstatic 19	org/htmlparser/util/Translate:ENCODE_HEXADECIMAL	Z
    //   180: ifeq +37 -> 217
    //   183: aload_3
    //   184: ldc_w 662
    //   187: invokevirtual 690	java/io/PrintWriter:print	(Ljava/lang/String;)V
    //   190: aload_3
    //   191: iload 7
    //   193: invokestatic 667	java/lang/Integer:toHexString	(I)Ljava/lang/String;
    //   196: invokevirtual 690	java/io/PrintWriter:print	(Ljava/lang/String;)V
    //   199: aload_3
    //   200: bipush 59
    //   202: invokevirtual 689	java/io/PrintWriter:print	(C)V
    //   205: goto -160 -> 45
    //   208: astore 4
    //   210: aload_3
    //   211: invokevirtual 693	java/io/PrintWriter:flush	()V
    //   214: aload 4
    //   216: athrow
    //   217: aload_3
    //   218: iload 7
    //   220: invokevirtual 698	java/io/PrintWriter:print	(I)V
    //   223: goto -24 -> 199
    //   226: aload_3
    //   227: iload 7
    //   229: invokevirtual 689	java/io/PrintWriter:print	(C)V
    //   232: goto -187 -> 45
    //   235: aload_3
    //   236: invokevirtual 693	java/io/PrintWriter:flush	()V
    //   239: goto -121 -> 118
    //
    // Exception table:
    //   from	to	target	type
    //   45	96	99	java/io/IOException
    //   170	205	99	java/io/IOException
    //   217	232	99	java/io/IOException
    //   0	45	119	java/io/UnsupportedEncodingException
    //   45	96	208	finally
    //   101	114	208	finally
    //   170	205	208	finally
    //   217	232	208	finally
  }

  protected static int lookup(CharacterReference[] paramArrayOfCharacterReference, char paramChar, int paramInt1, int paramInt2)
  {
    int i = -1;
    for (int j = 1 + paramInt2 - paramInt1; (-1 == i) && (paramInt1 <= paramInt2); j = k)
    {
      label11: int l;
      int i1;
      int i2;
      int k = j / 2;
      if ((j & 0x1) != 0)
        l = k;
      while (true)
      {
        while (true)
        {
          i1 = paramInt1 + l;
          i2 = paramChar - paramArrayOfCharacterReference[i1].getCharacter();
          if (i2 != 0)
            break label78;
          i = i1;
        }
        l = k - 1;
      }
      if (i2 < 0)
      {
        label78: paramInt2 = i1 - 1;
        if ((j & 0x1) != 0)
          j = k;
        while (true)
        {
          break label11:
          j = k - 1;
        }
      }
      paramInt1 = i1 + 1;
    }
    if (-1 == i)
      i = paramInt1;
    return i;
  }

  public static CharacterReference lookup(char paramChar)
  {
    CharacterReference localCharacterReference;
    if (paramChar < 256)
      localCharacterReference = mCharacterList[paramChar];
    while (true)
    {
      while (true)
      {
        do
        {
          return localCharacterReference;
          int i = lookup(mCharacterList, paramChar, 256, mCharacterList.length - 1);
          if (i >= mCharacterList.length)
            break label59;
          localCharacterReference = mCharacterList[i];
        }
        while (paramChar == localCharacterReference.getCharacter());
        localCharacterReference = null;
      }
      label59: localCharacterReference = null;
    }
  }

  public static CharacterReference lookup(String paramString, int paramInt1, int paramInt2)
  {
    CharacterReferenceEx localCharacterReferenceEx = new CharacterReferenceEx();
    localCharacterReferenceEx.setKernel(paramString);
    localCharacterReferenceEx.setStart(paramInt1);
    localCharacterReferenceEx.setEnd(paramInt2);
    return lookup(localCharacterReferenceEx);
  }

  protected static CharacterReference lookup(CharacterReference paramCharacterReference)
  {
    Object localObject = null;
    int i = Sort.bsearch(mCharacterReferences, paramCharacterReference);
    String str1 = paramCharacterReference.getKernel();
    if (i < mCharacterReferences.length)
    {
      localObject = mCharacterReferences[i];
      String str3 = ((CharacterReference)localObject).getKernel();
      if (!(str1.regionMatches(0, str3, 0, str3.length())))
        localObject = null;
    }
    if (localObject == null)
    {
      CharacterReference localCharacterReference;
      String str2;
      int j = str1.charAt(0);
      do
      {
        if (--i < 0)
          break label115;
        localCharacterReference = mCharacterReferences[i];
        str2 = localCharacterReference.getKernel();
        if (j != str2.charAt(0))
          break label115;
      }
      while (!(str1.regionMatches(0, str2, 0, str2.length())));
      localObject = localCharacterReference;
    }
    label115: return ((CharacterReference)localObject);
  }

  public static void main(String[] paramArrayOfString)
  {
    int i;
    if ((paramArrayOfString.length > 0) && (paramArrayOfString[0].equalsIgnoreCase("-encode")))
    {
      i = 1;
      if (i == 0)
        break label38;
      encode(System.in, System.out);
    }
    while (true)
    {
      while (true)
      {
        return;
        i = 0;
      }
      label38: decode(System.in, System.out);
    }
  }
}